from flask import Flask, request
from flask_migrate import Migrate
from flask_cors import CORS
from exts import create_app
from flask_migrate import Migrate
import logging

# 蓝图
from blueprints import (
    login_bp, 
    register_bp, 
    forgetpasswd_bp, 
    getimg_bp, 
    task_bp, 
    content_bp,
    manage_bp,
    master_manage_bp,
    about_money_bp,
    admin_bp
    )
# 配置
import config
from exts import db, mail

app, migrate = create_app()
# # app对象
# app = Flask(__name__)
# # 导入配置
# app.config.from_object(config)
# # 允许跨域
# CORS(app, resources=r'/*')
# # db对象
# db.init_app(app)
# # 绑定邮箱
# mail.init_app(app)
# # migrate用于操作数据库迁移
# migrate = Migrate(app, db)
# 写入日志
# logging.basicConfig(level=logging.DEBUG, filename="rewardrun.log", filemode='a', format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")

# 注册蓝图
app.register_blueprint(login_bp) # 登录模块
app.register_blueprint(register_bp) # 用户注册模块
app.register_blueprint(forgetpasswd_bp) # 用户忘记密码模块
app.register_blueprint(getimg_bp) # 用户获取图片的模块
app.register_blueprint(task_bp) # 用户任务相关的模块
app.register_blueprint(content_bp) # 用户审核通过任务的展示模块
app.register_blueprint(manage_bp) # 用户自我任务管理模块
app.register_blueprint(master_manage_bp) # 雇主用户自我任务管理模块
app.register_blueprint(about_money_bp) # 此接口为用户的充值提现模块
app.register_blueprint(admin_bp) # 此接口为管理员用户模块


@app.route("/", methods=["POST", "GET"])
def index():
    return "hello, flask reward"

if __name__ == '__main__':
    # 服务器运行
    # app.run(host="0.0.0.0")
    # 本地运行
    app.run()
